<template>
	<yd-layout id='my' class=''>
		<div class="header">
			<div class="header_top" @click="goNext('set')">
				<img class="header_img" :src="dataObj.avatar" alt="" />
				<div class="header_user">
					<div class="header_name c_text_ellipsis_1">
						<div class="header_name_c">{{dataObj.nick_name}}</div>
						<img v-if="dataObj.member_status==1" class="header_vip" src="../../assets/vip_2.png" alt="" />
						<img class="header_vip" v-if='dataObj.member_status==2' src="../../assets/vip_1.png" alt="" />
					</div>
					<div class="header_id">ID:{{dataObj.id}}</div>
				</div>
				<img class="header_icon" src="../../assets/bd_img/right.png" alt="" />
			</div>
			<div class="header_bottm">
				<div class="header_bottom_list">
					<div @click="goNext('myCollect')" class="header_bottom_num">{{collectCount}}</div>
					<div @click="goNext('myCollect')" class="header_bottom_label">我的收藏</div>
				</div>
				<div class="header_bottom_list">
					<div @click="goNext('myHeart')" class="header_bottom_num">{{commentCount}}</div>
					<div @click="goNext('myHeart')" class="header_bottom_label">我的心声</div>
				</div>
				<div class="header_bottom_list">
					<div @click="goNext('myStudy')" class="header_bottom_num">{{learnCount}}</div>
					<div @click="goNext('myStudy')" class="header_bottom_label">学习记录</div>
				</div>
			</div>
		</div>

		<div class="list">
			<div class="list_item" @click="goNext('wallet')">
				<img src="../../assets/my_3.png" alt="" />
				<span class="c_size_34_48">钱包</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('vipOpen')">
				<img src="../../assets/my_2.png" alt="" />
				<span class="list_item_time c_size_34_48">
					<div>商学院会员</div>
					<div class="list_item_time_c" v-if="dataObj.member_status==1">{{dataObj.newTime}}&nbsp;到期</div>
					<div class="list_item_time_c" v-else-if="dataObj.member_status==2">已到期</div>
					<div class="list_item_time_c" v-else>未开通</div>
				</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext()">
				<img src="../../assets/my_4.png" alt="" />
				<span class="c_size_34_48">开直播</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('myOrder')" style="border-bottom: .2rem solid #FAFAFA ;">
				<img src="../../assets/my_7.png" alt="" />
				<span class="c_size_34_48">我的订单</span>
				<i></i>
			</div>
			<!--<div class="list_item" @click="goNext('myShareApp')">
				<img src="../../assets/my_5.png" alt="" />
				<span class="c_size_34_48">商城</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('myShareApp')">
				<img src="../../assets/my_5.png" alt="" />
				<span class="c_size_34_48">订单</span>
				<i></i>
			</div>-->
			
			<div class="list_item" @click="goNext('myShareApp')">
				<img src="../../assets/my_5.png" alt="" />
				<span class="c_size_34_48">下载商学院APP</span>
				<i></i>
			</div>
			<div class="list_item" @click="goNext('set')" style="border-bottom: none;">
				<img src="../../assets/my_6.png" alt="" />
				<span class="c_size_34_48">设置</span>
				<i></i>
			</div>
		</div>
		<!--路由套壳的感觉差不多-->
		<Footer slot='bottom' activeStr='my'></Footer>
	</yd-layout>
</template>

<script>
	import Footer from '../../components/Footer/Footer.vue'
	export default {
		components: {
			[Footer.name]: Footer
		},
		data() {
			return {
				dataObj: {},
				collectCount: 0,
				learnCount: 0,
				commentCount: 0,
			}
		},
		created() {},
		watch: {

		},
		computed: {

		},
		mounted() {
			document.title = '我的'
			this.$root.ajax({
				name: 'my/index',
				type: 'get',
				params: {

				}
			}).then((d) => {
				d.data.user.newTime = this.$root.getDate(new Date(d.data.user.member_exp * 1000))
				this.dataObj = Object.assign({}, this.dataObj, d.data.user)
				this.collectCount = d.data.collect_count
				this.learnCount = d.data.learn_count
				this.commentCount = d.data.comment_count
			})
		},
		methods: {
			goNext(str) {

				if(str) {
					let params = {
						name: str
					}
					if(str == 'myHeart') {
						params.query = {
							uid: this.dataObj.id
						}
						this.$router.push(params)
					} else if(str == 'myShareApp') {
						window.location = this.$root.config.downAppUrl
					} else {
						this.$router.push(params)
					}

				} else {
					this.$dialog.confirm({
						title: '温馨提示',
						mes: '微信端暂不支持开直播',
						opts: [{
							txt: '知道了',
							color: '#35BF7E',
							callback: () => {

							}
						}]
					});
				}
			}
		}
	}
</script>

<style lang="scss">
	@import './my.scss';
</style>